import urwid


def main():
    palette = [
        ('header', 'yellow,bold', 'dark green'),
        ('footer', 'white', 'dark green'),
        ('streak', 'black', 'dark green'),
        ('body_bg', 'black', 'default'),
        ('body_text', 'light cyan', 'default'), ]

    def exit_on_q(input):
        if input in ('q', 'Q'):
            raise urwid.ExitMainLoop()

    body_0 = urwid.Pile([urwid.Text(('body_text', u'user 1')), urwid.Text(('body_text', u'user 2')), urwid.Text(('body_text', u'user 3'))])
    body_0 = urwid.AttrMap(body_0, 'body_bg')
    body_0 = urwid.Filler(body_0, 'top')
    body_0 = urwid.AttrMap(body_0, 'body_bg')
    body_0 = urwid.LineBox(body_0)

    body_1 = urwid.Text(u'body_1')
    body_1 = urwid.AttrMap(body_1, 'body_bg')
    body_1 = urwid.Filler(body_1, 'middle')
    body_1 = urwid.AttrMap(body_1, 'body_bg')
    body_1 = urwid.LineBox(body_1)

    body_2 = urwid.Text(u'body_2')
    body_2 = urwid.AttrMap(body_2, 'body_bg')
    body_2 = urwid.Filler(body_2, 'bottom')
    body_2 = urwid.AttrMap(body_2, 'body_bg')
    body_2 = urwid.LineBox(body_2)

    body_view = urwid.Columns([('weight', 1, body_0), ('weight', 3, body_1), ('weight', 1, body_2)])

    header = urwid.Text(('header', u'CHATTING ROOM'), align='center')
    header = urwid.AttrMap(header, 'streak')
    header_view = header

    footer = urwid.Edit(('footer', u'> '))
    footer = urwid.AttrMap(footer, 'footer')
    footer_view = footer

    frame = urwid.Frame(body_view, header=header_view, footer=footer_view)
    loop = urwid.MainLoop(frame, palette=palette, unhandled_input=exit_on_q)
    loop.run()


main()
